<?php
/*
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 *留言记录
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'list';
$tabs=array(
	array('op'=>'list','title'=>'申请列表'),
);
$return['status']=$this->joblog_status;
if($_RQ['op']=='list'){
	$type=intval($_RQ['type']);
	$params=array('uniacid'=>$_SESSION['uniacid']);
	if(!empty($_RQ['itemid'])){
		$params['itemid']=intval($_RQ['itemid']);
		$return['params']['itemid']=intval($_RQ['itemid']);
	}
	if(!empty($_RQ['jobtitle'])){
		$jobids=pdo_getall('jy_aihire_job',array('uniacid'=>$_SESSION['uniacid'],'title like %'=>$_RQ['jobtitle'].'%'),'id','id');
		$jobids=$jobids?:-1;
		$params['itemid']=$jobids;
		$return['params']['jobtitle']=$_RQ['jobtitle'];
	}
	if(!empty($_RQ['username'])){
		$memberids=pdo_getall('jy_aihire_member',array('uniacid'=>$_SESSION['uniacid'],'username like %'=>$_RQ['username'].'%'),'id','id');
		$memberids=$memberids?:-1;
		$params['memberid']=$memberids;
		$return['params']['username']=$_RQ['username'];
	}
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$total='';
	$list=pdo_getslice('jy_aihire_job_log',$params,array($pindex,$psize),$total,$fields,'','id desc');
	foreach($list as &$item){
		$item['member']=$this->model('member')->member_show($item['memberid']);
		$item['jobtitle']=pdo_getcolumn('jy_aihire_job',array('uniacid'=>$_SESSION['uniacid'],'id'=>$item['jobid']),'title');
	}
	$return['list']=$list;
	$totalpage=ceil($total/$psize);
	$totalpage=intval($totalpage);
	$return['totalpage'] =$totalpage;
	$return['params']['page'] =$pindex;
	$htmls=array(
		'type'=>'list',
		'tabs'=>$tabs,
		'list'=>array('data'=>'list','edit'=>false,'list'=>array(
			array('name'=>'member','title'=>'用工信息','type'=>'member'),
			array('name'=>'jobtitle','title'=>'工作名称','type'=>'string'),
			array('name'=>'comment','title'=>'申请内容','type'=>'string'),
			array('name'=>'createtime','title'=>'时间','type'=>'time'),
			array('name'=>'status','title'=>'状态','type'=>'radio','options'=>'status'),
		),'action'=>array(
		)),
		'search'=>array(
			array('name'=>'jobtitle','width'=>15,'title'=>'工作名称','type'=>'string'),
			array('name'=>'username','width'=>15,'title'=>'申请人姓名','type'=>'string'),
		)
	);
	$return['htmls']=$htmls;
	exi($return);
}
if($_RQ['op']=='del'){
	$del=trim($_RQ['del'],';');
	if($del){
		$del=explode(';',$del);
	}else{
		$del=array();
	}
	if($_RQ['id']){
		$del[]=$_RQ['id'];
	}
	foreach($del as $id){
		$id=intval($id);
		if($id){
			pdo_delete('jy_aihire_job_log',array('id'=>$id,'uniacid'=>$_SESSION['uniacid']));
		}
	}
	exi('删除成功！');
}
